//
//  ResetPasswordWithEmailViewController.m
//  Daybook
//
//  Created by dllo on 16/6/3.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "ResetPasswordWithEmailViewController.h"
#import "Common.h"
#import <BmobSDK/Bmob.h>

@interface ResetPasswordWithEmailViewController ()

@property (nonatomic, strong)UITextField *emailTextField;

@end

@implementation ResetPasswordWithEmailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createView];
}

- (void)createView {
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(10, 34, 25, 25);
    [self.view addSubview:backButton];
    backButton.backgroundColor = [UIColor clearColor];
    
    [backButton setImage:[UIImage imageNamed:@"backArrow"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(clickBack:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    self.emailTextField = [[UITextField alloc]initWithFrame:CGRectMake(10, 100, MAIN_WIDTH - 20, 40)];
    self.emailTextField.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.emailTextField];
    
    self.emailTextField.placeholder = @"您的邮箱号码";
    
    
    UIView *firstLineView = [[UIView alloc]initWithFrame:CGRectMake(0, 100, MAIN_WIDTH, 1)];
    firstLineView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:firstLineView];
    
    
    UIView *secLineView = [[UIView alloc]initWithFrame:CGRectMake(0, 140, MAIN_WIDTH, 1)];
    secLineView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:secLineView];
    
    
    
    
    UIButton *loginButton  = [UIButton buttonWithType:UIButtonTypeCustom];
    loginButton.frame = CGRectMake(10, 160, MAIN_WIDTH - 20, 40);
    loginButton.backgroundColor  = [UIColor orangeColor];
    [self.view addSubview:loginButton];
    
    [loginButton setTitle:@"发送邮件" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(clickSend:) forControlEvents:UIControlEventTouchUpInside];
    loginButton.layer.cornerRadius = 5;
    loginButton.layer.masksToBounds = YES;
    


}

- (void)clickBack:(UIButton *)button {
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}


- (void)clickSend:(UIButton *)button {
    
    [BmobUser requestPasswordResetInBackgroundWithEmail:self.emailTextField.text];
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
